home *** CD-ROM | disk | FTP | other *** search
- #include "bbs.h"
-
-
- int Chat(void)
- {
- extern int ChatSerFlag,ChatConFlag;
- extern struct myst my_struct;
- register int c;
- int j,x,i,back,WhichCon,WhichSer;
- char str[100],str2[10],SPACE[90],buff[256];
- FILE *fp;
-
- /* check for out cycled chat start sayings */
- if(my_struct.startchatnum > 0) { /* do we have a chat file ?? */
- if(!(fp = fopen(my_struct.startchatfile,"r")))
- goto wx;
-
- buff[0] = '\0';
- j = rand() % my_struct.startchatnum;
- i = 0;
- while(fgets(buff,80,fp)!=0) {
- if(i >= j) break;
- i++;
- }
- fclose(fp);
- i = 0;
- if(buff[0] == '\0') goto wx;
- sprintf(GSTR1,"\r\n\r\n%s\r\n\r\n",buff);
- AEPutStr(GSTR1);
- goto sx;
- }
-
- wx: Check_Online_Status();
- sprintf(GSTR1,"%sStartChat",NodeStr);
-
- if(!(i=ChecktoDisplay(GSTR1,GSTR2,0,0))) {
- AEPutStr("\r\n\r\nThis is ");
- AEPutStr(Cmds->SysopName);
- AEPutStr(", How can I help you??\r\n\r\n");
- }
-
- sx:
- PagedFlag=0;
- ChatConFlag=1;
- if(AnsiColor) {
- sprintf(str,"%dm",Cmds->AcLvl[24]);
- FAEPutStr(str);
- }
-
- ChatSerFlag=0;
- SPACE[0]='\0';
- str[0]='\0';
- x=0;
- while(ChatFlag){
- Next:
- WhichCon=ChatConFlag;
- WhichSer=ChatSerFlag;
- Next2:
- c=ReadChar(KEYBOARD_TIMEOUT);
- if(c==HISTORY) goto Next2;
- if(ChatFlag==0) break;
- if(c==NO_CARRIER) { ChatFlag=0; return(NO_CARRIER); }
- if(c=='\003' && GET_BIT(ACS_BREAK_CHAT)) { ChatFlag=0; break; }
- if(c=='\r') {
- if(CaptureFP)
- fprintf(CaptureFP,"%s\n",SPACE);
-
- /***** SIMILATES THE F1 'exit chat' routine *****/
- strupr(SPACE);
-
- SPACE[0]='\0';
- x=0;
- FAEPutStr("\r\n");
- Check_Online_Status();
- goto Next2;
- }
-
- if(c=='\b' || c=='\177') {
- if(x>0) {
- x-=1;
- SPACE[x]='\0';
- FAEPutStr("\b \b");
- goto Next2;
- }
- goto Next2;
- }
- if(c==''||c=='\07') {
- SendChar(c);
- goto Next2;
- }
- if(c<' ') goto Next2;
-
- x+=1;
- if(AnsiColor) {
- if(ChatConFlag==1&&WhichSer==1) {
- sprintf(str,"%dm",Cmds->AcLvl[24]);
- if(BitPlanes<3) SerPutStr(str);
- else FAEPutStr(str);
- }
- if(ChatSerFlag==1&&WhichCon==1) {
- sprintf(str,"%dm",Cmds->AcLvl[25]);
- if(BitPlanes<3) SerPutStr(str);
- else FAEPutStr(str);
- }
- SendChar(c);
- } else SendChar(c);
-
- str2[0]=(char)c;
- str2[1]='\0';
- strcat(SPACE,str2);
-
- if(x>78) {
- back=0;
- for(i=x; i>=0; i--) {
- if(SPACE[i-1]==' ') {
- back=x-i;
- break;
- }
- }
- if(back==0) {
- if(CaptureFP)
- fprintf(CaptureFP,"%s\n",SPACE);
-
- FAEPutStr("\r\n");
- SPACE[0]='\0';
- x=0;
- goto Next;
- }
- str[0]='\0';
- for(i=(x-back); i<x; i++) {
- str2[0]=SPACE[i];
- str2[1]='\0';
- strcat(str,str2);
- }
-
- if(CaptureFP) {
- if(x-back-1>=0) {
- SPACE[x-back-1]='\0';
- }
- fprintf(CaptureFP,"%s\n",SPACE);
- }
-
- x=strlen(str);
- strcpy(SPACE,str);
- for(i=0; i<x; i++)
- FAEPutStr("\b \b");
-
- FAEPutStr("\r\n");
- FAEPutStr(str);
- }
- }
-
- (void)StatPrintUser(&User);
- if(AnsiColor) AEPutStr("");
-
- /*---------------- check for our cycled chat stop sayings ------------*/
- if(my_struct.stopchatnum > 0) { /* do we have a chat file ?? */
- if(!(fp = fopen(my_struct.stopchatfile,"r")))
- goto wy;
-
- buff[0] = '\0';
- j = rand() % my_struct.stopchatnum;
- i = 0;
- while(fgets(buff,80,fp)!=0) {
- if(i >= j) break;
- i++;
- }
- fclose(fp);
- i = 0;
- if(buff[0] == '\0') goto wy;
- sprintf(GSTR1,"\r\n\r\n%s\r\n",buff);
- AEPutStr(GSTR1);
- return(SUCCESS);
- }
-
-
- wy:
- sprintf(GSTR1,"%sEndChat",NodeStr);
- if(!(i=ChecktoDisplay(GSTR1,GSTR2,0,0)))
- wz: AEPutStr("\r\n\r\nEnding Chat.");
-
- return(SUCCESS);
- }
-